<?php
namespace Modules\BlogAdmin\Http\Controllers;
use Illuminate\Http\Request;
use Modules\Admin\Http\Requests\CommonStatusRequest;
use Modules\Admin\Http\Requests\CommonSortRequest;
use Modules\Admin\Http\Requests\CommonDeleteRequest;
use Modules\BlogAdmin\Models\BlogColumn as BlogColumnModel;
use Modules\Admin\Http\Controllers\CommonController;
class BlogColumnController extends CommonController
{
	/**
	 * @name  列表
	 */
    public function index()
    { 
        return view('blogadmin::blog_column.index');
    }
	/**
	 * @name  列表数据
	 */
	 
    public function data(Request $request)
    {
        $arr = BlogColumnModel::orderBy('pid','asc')->orderBy('sort','asc')->get();
		foreach($arr as $k=>$v){
			$arr[$k]['lay_is_open']=false;
		}
		return response()->json(["code"=>0,"msg"=> config('admin.limit_msg'),"data"=>$arr,"is"=>true,"tip"=>"操作成功"]);		
    }
	/**
	 * @name  添加页面
	 */
    public function create()
    { 
		$auth_rule_info = (new BlogColumnModel)->lefts();
		return view('blogadmin::blog_column.create',compact('auth_rule_info'));
    }
	/**
	 * @name  添加数据处理 
	 */
    public function store(Request $request)
    {
		return (new BlogColumnModel)->common_create($request->all(),route('blog_admin.column.index'));  
    }
	/**
	 * @name  添加子级页面
	 */
    public function create_sublevel($id)
    {   
		$blog_column_info = BlogColumnModel::find($id);
		return view('blogadmin::blog_column.create_sublevel',compact('blog_column_info'));
    }
	/**
	 * @name  添加子级数据处理
	 */
    public function store_sublevel(Request $request)
    {
		return (new BlogColumnModel())->common_create($request->all(),route('blog_admin.column.index'));
    }
	/**
	 * @name  编辑页面
	 */
    public function edit($id)
    {
		$info = BlogColumnModel::find($id);
		return view('blogadmin::blog_column.edit',compact('info'));
    }
	/**
	 * @name  编辑数据处理
	 */
    public function update(Request $request,$id)
    {
		return (new BlogColumnModel())->common_update($request->all(),$id,route('blog_admin.column.index')); 
    }
	/**
	 * @name  调整状态数据处理
	 */
    public function status(CommonStatusRequest $request,$id)
    {
		return (new BlogColumnModel())->common_status_update($request->all(),$id,route('blog_admin.column.index')); 
    }
	/**
	 * @name  排序数据处理
	 */
    public function sorts(CommonSortRequest $request,$id)
    {
		return (new BlogColumnModel())->common_status_update($request->all(),$id,route('blog_admin.column.index'));  
    }
	/**
	 * @name  删除数据处理
	 */
    public function destroy(CommonDeleteRequest $request)
    {
		return (new BlogColumnModel())->column_delete($request->get('id'),route('blog_admin.column.index'));  
    }
	
	
	
	
	
	
}
